package com.wc.alorithm_luogu.P1873_砍树;

import java.io.PrintWriter;
import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/3/17 9:58
 * @description https://www.luogu.com.cn/problem/P1873
 */
public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 1000010;
    static int[] a = new int[N];
    static int n, m;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
        int l = 0, r = 400000;
        while (l < r) {
            int mid = l + r + 1 >> 1;
            if (check(mid)) l = mid;
            else r = mid - 1;
        }
        out.println(r);
        out.flush();
    }

    static boolean check(int mid) {
        long res = 0;
        for (int i = 1; i <= n; i++) {
            res += Math.max(0, a[i] - mid);
        }
        return res >= m;
    }
}